<template>
  <div id="bar">
    <div class="container">
      <div>
        <ol class="breadcrumb">
          <li><a href="#">超级签名</a></li>
          <li><a href="#">应用列表</a></li>
          <li class="active">购买</li>
        </ol>
      </div>
      <el-row>
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <div class="content">
            <div style="padding-bottom: 80px">
              <el-row :gutter="60">
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                  <div class="title1">选择套餐内容</div>
                </el-col>
                <el-col :xs="0" :sm="0" :md="2" :lg="2" :xl="2"></el-col>
                <!-- 套餐 -->
                <el-col :xs="24" :sm="24" :md="10" :lg="12" :xl="12" v-for="(item, index) in mealContent" :key="index">
                  <div>
                    <div class="input-group" @click="itemSelect(index,item)">
                      <div class="form-control panel1" :id="itemSort===index?'panel1':'panel2'">
                        {{item.title}}
                        <div class="text1">{{item.des}}</div>
                      </div>
                      <span class="input-group-btn">
                        <div class="btn btn-default box1" :id="itemSort===index?'box1':'box2'">
                          <div :class="itemSort===index?'price1':'price2'">{{item.price}}<span>元</span></div>
                          <div :class="itemSort===index?'ran1':'ran2'">可享最低优惠</div>
                        </div>
                      </span>
                    </div>
                  </div>
                </el-col>
                <el-col :xs="0" :sm="0" :md="2" :lg="2" :xl="2"></el-col>
              </el-row>
              <!-- 数量 -->
              <el-row>
                <el-col :xs="24" :sm="3" :md="3" :lg="3" :xl="3">
                  <div class="title1">购买数量：</div>
                </el-col>
                <el-col :xs="24" :sm="20" :md="20" :lg="20" :xl="20">
                  <div class="number">
                    <div class="num_box" v-for="(item, index) in num" :key="index" @click="active(index,item)"
                      :class="{'line':currentSort===index}">
                      <div class="discounts" v-if="item.title!=='1'">
                        <div class="sale">
                          <p>优惠</p>
                        </div>
                      </div>
                      <div class="discounts" v-if="item.title=='1'">
                        <div class="sale1"></div>
                      </div>
                      <div class="item" :style="item.title !=='1'?'margin-top: 16px;':''">{{item.title}}个</div>
                      <div class="unit"><span v-if="item.title!=='1'">每个只需</span> {{item.price}}元</div>
                    </div>
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :xs="24" :sm="3" :md="3" :lg="3" :xl="3">
                  <div class="title2">支付方式：</div>
                </el-col>
                <el-col :xs="24" :sm="20" :md="20" :lg="20" :xl="20">
                  <div style="margin-top: 70px; margin-left: 20px">
                    <el-button class="wx_button" :class="{payTypeBorder:selectPayType == 'weixin'}"
                      @click="payTypeSelect(1)"><img src="../../../static/price/QianMinTaoCan_WeChat.png" alt=""
                        style="background-color: #00c900;" />&nbsp;微信</el-button>
                    <el-button class="wx_button" :class="{payTypeBorder:selectPayType=='zfb'}"
                      @click="payTypeSelect(2)"><img src="../../../static/price/QianMinTaoCan_Alipay.png" alt=""
                        style="background-color: #5a9ff7;" />&nbsp;支付宝&nbsp;&nbsp;</el-button>
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :xs="24" :sm="3" :md="3" :lg="3" :xl="3">
                  <div class="title2">总支付：</div>
                </el-col>
                <el-col :xs="24" :sm="20" :md="20" :lg="20" :xl="20" class="price">
                  <span>{{payPrice}}</span>&nbsp;元 <span class="wu" v-show="payPrice==20||payPrice==5">(当前无优惠)</span>
                  <span class="youhui" v-show="payPrice!==20&&payPrice!==5">(享受优惠中，原价￥{{originalPrice}})</span>
                </el-col>
                <div>
                  <el-button class="pay_button" @click="gotPay()">去支付</el-button>
                </div>
              </el-row>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
  export default {
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
      //这里存放数据
      return {
        radio: 1,
        color: 'rgb(255,119,34)',
        mealContent: {}, //套餐列表
        price: '',
        num: [], //空数组
        public: [], //公有
        private: [], //私有
        payPrice: '', //支付金额
        currentSort: 0, //选中数量
        itemSort: 0, //选中套餐
        originalPrice: '', //原价
        selectPayType: 'weixin', //weixin,zfb
        getPayWay: 1, //1微信 2支付宝
        selectNum: '', //选中数量
        getCode: '', //类型

      };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      pcPay() {
        var params = new URLSearchParams();
        this.$post(this.API.payIndexSuper).then((res) => {
          console.log(res, "8080");
          let data = res.data;
          this.mealContent = data.list;
          console.log(this.mealContent);
          this.public = data.list[0].list;
          this.private = data.list[1].list;
          this.payPrice = data.list[0].list[0].payPrice;
          this.originalPrice = data.list[0].list[0].originalPrice;
          this.num = this.public;
          this.selectNum = data.list[0].list[0].title;
          this.getCode = data.list[0].list[0].cpde;
          console.log(this.payPrice);

        });
      },
      //选择公有或私有
      itemSelect(index, item) {
        this.itemSort = index;
        if (this.itemSort == 0) {
          this.currentSort = 0;
          this.payPrice = this.public[0].payPrice;
          this.num = this.public;
          this.getCode = item.list[0].cpde;
          // console.log(this.getCode,"kkjkk");
        } else {
          this.currentSort = 0;
          this.payPrice = this.private[0].payPrice;
          this.num = this.private;
          this.getCode = item.list[0].cpde;
          // console.log(this.getCode,"kkkkk");
        }
        console.log(this.itemSort, "index111");
        console.log(this.num, "??");
      },
      active(index, item) {
        this.currentSort = index;
        //点击变化价格
        this.selectNum = item.title;
        console.log(this.selectNum, "数量");
        this.getCode = item.cpde;
        console.log(this.getCode, "类型");
        this.originalPrice = item.originalPrice;
        this.payPrice = item.payPrice;
        console.log(this.payPrice, "支付价格");
        console.log(this.currentSort, "index");
      },
      //选择支付方式
      payTypeSelect(type) {
        this.selectPayType = type == 1 ? "weixin" : "zfb";
        this.getPayWay = type;
        console.log(type);

      },
      //提交支付
      gotPay() {
        var params = new URLSearchParams();
        params.append("payIndex", this.getCode);
        params.append("num", this.selectNum);
        params.append("paytype", this.getPayWay);
        this.$post(this.API.Payment, params).then((res) => {
          let data = res.data;
          this.orderID = data.orderid;
          // console.log(res);
          if (this.selectPayType == "zfb") {
            document.querySelector("body").innerHTML = res.data; //查找到当前页面的body，将后台返回的form替换掉body内容
            document.forms[0].submit();
          } else {
            //微信
            this.$router.push({
              path: "/wechat",
              name: "wechat",
              query: {
                orderID: this.orderID,
                num: this.selectNum,
                code: this.getCode,

              },
            });
          }
        });
      },
    },

    //生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.pcPay();
      this.color = this.$route.query.color;
      // this.getCode=this.$route.query.code;
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
  };

</script>
<style scoped>
  /* 支付方式选中 start*/
  div>>>.payTypeBorder {
    border: 2px solid #FF7226 !important;
  }

  /* 支付方式选中 end*/
  #bar {
    width: 100%;
    min-height: 472px;
    background-color: #000;
    overflow: hidden;
  }

  .price .wu {
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
  }

  .price .youhui {
    height: 12px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #F65D26;
  }

  .item {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;

  }

  .unit {
    font-size: 20px;
    font-family: PingFang-SC-Bold, PingFang-SC;
    font-weight: bold;
    color: #ec7a2d;
    margin-bottom: 2px;
  }

  .unit span {
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;
    margin-right: -4px;
  }

  .discounts {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
  }

  .sale {
    width: 60px;
    height: 60px;
    border-radius: 0px 2px 0px 2px;
    color: #fff;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    text-align: center;
    line-height: 20px;
    /* vertical-align: bottom; */
    border-bottom: 30px solid #ee792d;
    border-top: 30px solid transparent;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    transform: rotate(-45deg);
    position: absolute;
    top: -30px;
    left: -30px;
  }

  .sale p {
    width: 30px;
    height: 20px;
    position: absolute;
    top: 8px;
    right: -15px;
  }

  .sale1 {
    width: 38px;
    height: 16px;
    background: transparent;
  }

  .number {
    display: flex;
    flex-flow: row wrap;
  }

  .num_box {
    width: 140px;
    height: 80px;
    border-radius: 2px;
    /* border: 1px solid #FF7226; */
    background-color: #272727;
    margin-left: 20px;
    margin-top: 40px;
    display: flex;
    /* justify-content: center;
    align-items: center; */
    text-align: center;
    flex-direction: column;
    cursor: pointer;
  }

  .line {
    border: 1px solid #ec7a2d;
  }

  div>>>.pay_button {
    width: 180px;
    height: 50px;
    background-image: linear-gradient(to right, #f59833, #f95810);
    border-radius: 4px;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 18px;
    padding: 0px;
    border: none;
    margin-left: 150px;
    margin-top: 40px;
  }

  .price {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;
    line-height: 16px;
    margin-top: 80px;
    margin-bottom: 10px;
    margin-left: 4px;
  }

  .price span {
    font-size: 26px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #F65D26;
    line-height: 20px;
  }

  div>>>.wx_button {
    border: 2px solid #FF7226;
  }

  div>>>.wx_button {
    width: 180px;
    height: 80px;
    background: #272727;
    border-radius: 4px;
    border: 0px;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #fff;
    line-height: 20px;
  }

  div>>>.wx_button img {
    margin-top: -4px;
    margin-left: -8px;
    display: inline-block;
    width: 25px;
    height: 25px;
    border-radius: 50%;
  }

  div>>>.wx_button span {
    margin-top: -px;
  }

  div>>>.buttonurl {
    background: #03a0ec;
    border-radius: 8px;
    color: #fff;
    width: 114px;
    height: 40px;
    font-size: 16px;
    text-align: center;
  }

  .but {
    margin-left: 120px;
    margin-top: -35px;
  }

  .textOne {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #000000;
    line-height: 20px;
  }

  .textOne span {
    font-size: 26px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f65d26;
    line-height: 20px;
    margin: 0px 5px 0px 0px;
  }

  .textTwo {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #5a5e66;
    line-height: 14px;
    margin: 18px 0px 18px 0px;
  }

  .wxicon {
    margin: -5px 3px 0px 0px;
  }

  .wechat {
    font-size: 20px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #000000;
    line-height: 20px;
    margin: -28px 0px 0px 35px;
  }



  .content {
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    background-color: #0f0f0f;
  }

  .breadcrumb {
    background: none;
  }

  .breadcrumb li a {
    color: #ee792f;
  }

  .breadcrumb li.active {
    color: #fff;
  }

  .title1 {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    padding: 40px 0px 0px 24px;
    color: #fff;
  }

  .title2 {
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    font-size: 16px;
    margin: 80px 0px 0px 24px;
    color: #fff;
  }

  .title3 {
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    font-size: 16px;
    padding: 40px 0px 0px 0px;
    margin-left: 10px;
    margin-right: 10px;
  }

  .title4 {
    padding: 60px 0px 0px 30px;
  }

  .title5 {
    padding: 85px 0px 0px 30px;
  }

  .textTwo1 {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #5a5e66;
    line-height: 14px;
    margin: 18px 0px 18px 0px;
  }

  .wxicon1 {
    margin: -5px 3px 0px 0px;
  }

  .wechat1 {
    font-size: 20px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #000000;
    line-height: 20px;
    margin: -28px 0px 0px 35px;
  }

  .border {
    display: flex;
  }

  #panel1 {
    height: 100px;
    background: #ee792d;
    border-radius: 0px;
    margin-left: 20px;
    /* margin-right: 20px; */
    margin-top: 20px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: none;
    cursor: pointer;
  }

  #panel2 {
    height: 100px;
    background: #1d1d1d;
    border-radius: 0px;
    margin-left: 20px;
    /* margin-right: 20px; */
    margin-top: 20px;
    color: #fff;
    border: 0px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
  }

  #box1 {
    width: 126px;
    height: 100px;
    background: #f95a11;
    border-radius: 0px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin-top: 20px;
    margin-right: 20px;
    border: none;
    cursor: pointer;
  }

  #box2 {
    width: 146px;
    height: 100px;
    background: #343434;
    border-radius: 0px;
    border: 0px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin-top: 20px;
    margin-right: 20px;
    cursor: pointer;
  }

  .text1 {
    font-family: "苹方-简 中黑体";
    font-size: 14px;
  }

  .text2 {
    font-family: "苹方-简 中黑体";
    font-size: 16px;
    color: #757575;
  }

  .price1 {
    font-size: 30px;
    color: #fff;
  }

  .price1 span {
    font-size: 14px;
    margin: 0px 5px;
    color: #fff;
  }

  .ran1 {
    color: #fff;
  }

  .price2 {
    font-size: 30px;
    color: #fff;
  }

  .price2 span {
    font-size: 14px;
    margin: 0px 5px;
    color: #fff;
  }

  .ran2 {
    color: #fff;
  }

  .pay {
    display: flex;
    flex-direction: row;
    margin-left: 10px;
  }

  div>>>.el-radio__input.is-checked .el-radio__inner {
    border-color: #ff720b;
    background: #ff720b;
  }

  div>>>.el-radio__input.is-checked+.el-radio__label {
    color: #ff720b;
  }

  .input-group-btn:last-child>.btn {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
  }

  /* 媒体查询 */

  @media (max-width: 992px) {
    .num_box {
      margin-top: 20px;
    }
  }

  @media (max-width: 768px) {}

  @media (max-width: 576px) {}

  @media (max-width: 375px) {

    .panel1,
    .panel2 {
      font-size: 12px;
    }

    .text1,
    .text2 {
      font-size: 14px;
    }

    .num_box {
      margin-top: 20px;
    }
  }

</style>
